﻿using DK.Sort;
using System.Collections;

int[] arr = new int[] { 10, 7, 6, 9, 3, 1, 5, 2, 4,8,7,7,7,7};

//冒泡排序
Console.WriteLine("\n冒泡排序:");
ISort bsort = new BubbleSort();
var barr = new List<int>(arr).ToArray();
bsort.Sort(barr);
foreach (var item in barr)
{
    Console.Write("{0} ", item);
}
Console.WriteLine();

//选择排序
Console.WriteLine("\n选择排序:");
ISort ssort = new SelectionSort();
var ssarr = new List<int>(arr).ToArray();
ssort.Sort(ssarr);
foreach (var item in ssarr)
{
    Console.Write("{0} ", item);
}
Console.WriteLine();

//插入排序
Console.WriteLine("\n插入排序:");
ISort isort = new InsertionSort();
var iarr = new List<int>(arr).ToArray();
isort.Sort(iarr);
foreach (var item in iarr)
{
    Console.Write("{0} ", item);
}
Console.WriteLine();


/*******************************复杂排序*******************************/
//希尔排序
Console.WriteLine("\n希尔排序:");
ISort shsort = new ShellSort();
var sharr = new List<int>(arr).ToArray();
shsort.Sort(sharr);
foreach (var item in sharr)
{
    Console.Write("{0} ", item);
}
Console.WriteLine();


//归并排序
Console.WriteLine("\n归并排序:");
ISort msort = new MergeSort();
var marr = new List<int>(arr).ToArray();
msort.Sort(marr);
foreach (var item in marr)
{
    Console.Write("{0} ", item);
}
Console.WriteLine();

//快速排序
Console.WriteLine("\n快速排序:");
QuickSort qsort = new QuickSort();
var qarr = new List<int>(arr).ToArray();
qsort.Sort(qarr);
foreach (var item in qarr)
{
    Console.Write("{0} ", item);
}
Console.WriteLine();